
from pydantic_settings import BaseSettings 

class Settings(BaseSettings):
    # MQTT 配置参数
    MQTT_BROKER: str = "localhost"  # 默认值
    MQTT_PORT: int = 1883
    MQTT_USERNAME: str | None = None
    MQTT_PASSWORD: str | None = None
    MQTT_KEEPALIVE: int = 60
    MQTT_CLIENT_ID: str = "fastapi-backend"
    MQTT_TOPICS: list[str] = ["sensors/#", "commands"]  # 订阅主题列表
    
    class Config:
        env_file = ".env"  # 从 .env 文件加载配置
        case_sensitive = True  # 区分环境变量大小写

settings = Settings()  # 创建配置实例